package com.surfilter.admin.project.monitor.controller;

import java.util.List;

import org.springframework.context.annotation.Configuration;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.surfilter.admin.framework.aspectj.lang.annotation.Log;
import com.surfilter.admin.framework.aspectj.lang.enums.BusinessType;
import com.surfilter.admin.project.monitor.domain.Gather;
import com.surfilter.admin.project.monitor.service.IGatherService;
import com.surfilter.admin.framework.web.controller.BaseController;
import com.surfilter.admin.framework.web.domain.AjaxResult;
import com.surfilter.admin.common.utils.poi.ExcelUtil;
import com.surfilter.admin.framework.web.page.TableDataInfo;

/**
 * 节点管理Controller
 * 
 * @author JinHuaTao
 * @date 2020-05-10
 */
@RestController
@RequestMapping("/monitor/gather")
public class GatherController extends BaseController
{
    @Autowired
    private IGatherService gatherService;

    /**
     * 查询节点管理列表
     */
    @PreAuthorize("@ss.hasPermi('monitor:gather:list')")
    @GetMapping("/list")
    public TableDataInfo list(Gather gather)
    {
        startPage();
        List<Gather> list = gatherService.selectGatherList(gather);
        return getDataTable(list);
    }

    /**
     * 导出节点管理列表
     */
    @PreAuthorize("@ss.hasPermi('monitor:gather:export')")
    @Log(title = "节点管理", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(Gather gather)
    {
        List<Gather> list = gatherService.selectGatherList(gather);
        ExcelUtil<Gather> util = new ExcelUtil<Gather>(Gather.class);
        return util.exportExcel(list, "gather");
    }

    /**
     * 获取节点管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('monitor:gather:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(gatherService.selectGatherById(id));
    }

    /**
     * 新增节点管理
     */
    @PreAuthorize("@ss.hasPermi('monitor:gather:add')")
    @Log(title = "节点管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Gather gather)
    {
        return toAjax(gatherService.insertGather(gather));
    }

    /**
     * 修改节点管理
     */
    @PreAuthorize("@ss.hasPermi('monitor:gather:edit')")
    @Log(title = "节点管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Gather gather)
    {
        return toAjax(gatherService.updateGather(gather));
    }

    /**
     * 删除节点管理
     */
    @PreAuthorize("@ss.hasPermi('monitor:gather:remove')")
    @Log(title = "节点管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(gatherService.deleteGatherByIds(ids));
    }
}
